package com.zee.activity.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zee.activity.R;
import com.zee.activity.ui.EventBusMainActivity;
import com.zee.activity.ui.RouteActivity;
import com.zee.log.ZLog;
import com.zee.utils.UIUtils;

import java.util.Stack;

public class TestFragmentLift extends Fragment {

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_test, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        final Stack<String> stack = new Stack<String>();
        for (int i = 0; i < 100; i++) {
            stack.add("第：" + i + "个");
        }

        view.findViewById(R.id.id_fragment_test).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ZLog.i("点击按钮");
//                while (stack.peek() != null) {
                    ZLog.i("测试： " + stack.pop());
//                }
//                startActivity(new Intent(getActivity(), RouteActivity.class));
            }
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        ZLog.i("测试生命周期");
    }

    @Override
    public void onPause() {
        super.onPause();
        ZLog.i("测试");
    }

    @Override
    public void onStop() {
        super.onStop();
        UIUtils.postDelayed(new Runnable() {
            @Override
            public void run() {
                ZLog.i("测试--》》时间到了。恭喜你任务完成");
            }
        }, 3000);

        ZLog.i("测试");
    }
}
